<include file="Public:header" />
<div style="background:#fff; height:40px; line-height:40px; border-bottom:1px solid #ccc; text-align:center;" class="headernav1"> <a href="javascript:history.go(-1);" style="height:40px; width:40px; display:block; float:left; text-align:center;"><i class="fa fa-angle-left"></i></a> <i style="color:#ff1b51;" class="fa fa-file-text-o"></i> 我的订单 <a href="{:U('Home/Cart/index')}" style="height:40px; width:40px; display:block; float:right; text-align:center;"><i class="fa fa-cart-plus"></i></a> </div>
<style>
@media (min-width: 50px) {
  .nav-justified>li {display: table-cell;width: 1%;}
}
body{background:#F4F4F4;}
.panel-body {padding: 5px 5px;  }
.panel {margin-bottom: 0px;}
.nav-justified>li>a {margin-bottom: 0;border-radius: 0;}
.headernav1 .fa{font-size:20px;}
.headernav,.panel-info{border:none;}
</style>

<div class="goods" style="padding:5px 0px;">
  <div class="panel panel-info">
    <div class="panel-heading">
      <h3 class="panel-title">订单详情</h3>
    </div>
    <div class="panel-body" style="background:#fff; padding:0;">
      <ul class="list-group" style="margin-bottom:0;">
        <li class="list-group-item" style="border-radius:0; border:none;">
          <p class="text-left">订单状态:
            <eq name="order['status']" value="0"> <strong style="color:red;">已取消</strong> </eq>
            <eq name="order['status']" value="1"> <strong style="color:#333;">待支付</strong> </eq>
            <eq name="order['status']" value="2"> <strong style="color:#ff1c51;">已支付</strong> </eq>
            <eq name="order['confirm']" value="1"> <strong style="color:#ff1c51;">已完成</strong> </eq>
            <eq name="order['status']" value="2">
              <eq name="order['shipping_status']" value="0"> 待发货 </eq>
              <eq name="order['shipping_status']" value="1"> 部分发货 </eq>
              <eq name="order['shipping_status']" value="2"> 全部发货 </eq>
              <eq name="order['shipping_status']" value="3"> 部分确认 </eq>
              <eq name="order['shipping_status']" value="4"> 全部确认 </eq>
            </eq>
          </p>
          <p class="text-left">订单编号：{$order.ordernumber}</p>
          <p class="text-left">订单金额：{$order.total}</p>
          <p class="text-left">下单时间: {$order.create_time|date='Y-m-d',###}</p>
        </li>
        <notempty name="order['tel']">
        <li class="list-group-item" style="border-radius:0; border:none; border-top:1px solid #eee;">
        <notempty name="order['yourname']">
          <p class="text-left">收货人姓名：{$order.yourname}</p>
          </notempty>
          <notempty name="order['address']">
          <p class="text-left">详细地址：{$order.address}</p>
          </notempty>
          <notempty name="order['tel']">
          <p class="text-left">电话号码：{$order.tel}</p>
          </notempty>
        </li>
       </notempty>
      </ul>
    </div>
  </div>
</div>
<div class="goods" style="padding:0px 0px;">
  <div class="panel panel-info">
    <div class="panel-body" style="background:#fff;">
        <?php  foreach($goods as $ko => $vo){ ?>
        <div class="panel-heading">
          <h3 class="panel-title">供货商:<?php echo D('Supplier')->where('id = '.$ko)->getfield('susername'); ?></h3>
        </div>
        <form action="{:U('confirmgoods')}" method="post">
          <input type="hidden" name="order_id" value="{$order.id}">
          <volist name="vo.product" id="pvo" key="i">
            <gt name="key" value="0"><hr></gt>
            <input type="checkbox" name="sale[]" id="product_id{$pvo.sale_id}" checked="checked"  value="{$pvo.sale_id}" style="display:none;">
            <!--<input type="hidden" name="ordernumber" value="{$order.ordernumber}" >-->
            <div class="media" style="width:100%; display:table;">
              <div class="media-left" style="width:90px;"> <a href="{:getArtLink($pvo['id'],1)}"> <img style="border:1px solid #ccc; padding:1px;" class="media-object" data-src="holder.js/64x64" alt="64x64" src="{:getThumbPath($pvo['img_url'],true)}" data-holder-rendered="true" width="100%"> </a> </div>
              <div class="media-body">
                <h4 class="media-heading">{$pvo.title}</h4>
                <p><strong style="color:#f00;">¥<?php  echo round($pvo['price'],2);  ?></strong> x <?php echo $pvo['num']; ?></p>
                <p>
                  <?php if(!empty($pvo['attrmes'][0])){?>
                  <span style="color:rgba(203,189,190,1.00)">规格:&nbsp;&nbsp;</span>
                  <?php foreach($pvo['attrmes'] as $vos){?>
                  <span><?php echo $vos;  ?>&nbsp;&nbsp;</span>
                  <?php }?>
                  <?php }?>
                </p>
                <?php if((M('Sale')->where(' order_id = '.$_GET['id'])->getField('price'))!=0.01){ ?>
                <p>数量：{$pvo.num}　<gt name="pvo['thnum']" value="0">退货：{$pvo.thnum}</gt></p>
                <?php } ?>
                <div class="row">
                  <div class="col-xs-6">
                    <if condition="$pvo.confirm eq 1">
                      <if condition="$pvo.thstatus eq 0 and $order.confirm neq 1"> 
                       <if condition="$pvo.autoconfirm eq 0"> 
                          <a class="btn btn-danger" style="display:block;" href="{:U('selecttype',array('sale_id'=>$pvo['sale_id']))}"> 申请售后 </a><else/>
                          <span style="color:#f00;">已经确认</span>
                       </if>
                      <else/>
                        <if condition="$order.confirm neq 1">
                        <a class="btn btn-danger" style="display:block;" href="{:U('selecttype',array('sale_id'=>$pvo['sale_id']))}"> 查看 </a>
                        </if>
                      </if>
                    </if>
                  </div>
                  <div class="col-xs-6">
                    <eq name="order.status" value="2">
                      <eq name="pvo.status" value="1"> <notempty name="vo['logistics_num']"><a href="http://m.kuaidi100.com/result.jsp?nu={$vo.logistics_num}" style="display:block;" class="btn btn-default">查看物流</a></notempty>
                        <else/>
                           <?php if((M('Sale')->where(' order_id = '.$_GET['id'])->getField('price'))!=0.01){ ?>
                        <eq name="pvo.thstatus" value="3"> <span style="text-align:center; display:block;">退款中</span> </eq>
                        <eq name="pvo.thstatus" value="0"> <a href="##" class="btn btn-default" style="display:block;" onClick="refund({$pvo.sale_id});">退款</a> </eq>
                        <?php } ?>
                      </eq>
                    </eq>
                  </div>
                </div>
                <notempty name="vo['logistics_num']">
                <div class="row" style="line-height:3; text-align:right; padding-right:10px;">
                  <eq name="order.status" value="2">
                    <eq name="pvo.status" value="1"> 快递：{:getShippingName($order['shipping_id'])}　单号：{$vo.logistics_num} </eq>
                  </eq>
                </div>
                </notempty>
              </div>
            </div>
          </volist>
          <div style="text-align:right;line-height:30px;margin-top:10px;">
            配送费用：<?php echo $vo['fee'];?>
          </div>
          <eq name="order.status" value="2">
            <eq name="pvo.status" value="1">
              <div class="row">
                <div class="col-xs-12" style="text-align:right; padding-top:8px; padding-bottom:1rem;">
                  <!--  查看物流 , 确认收货 --> 
                  <!--  如果未确认收货可以查看物流 -->
                       <eq name="pvo.thstatus" value="3"> <span style="text-align:center; display:block;">退换货中</span> </eq>
                      
                        <eq name="pvo.thstatus" value="0"> <a href="##" class="btn btn-default"  onClick="refund({$pvo.sale_id});">申请退换货</a> </eq>
                       
                        <neq name="pvo.thstatus" value="4">   <eq name="pvo.confirm" value="0">  <button id="is_goods" type="submit" class="btn btn-success" onClick="return confirm('您确定已经收货？');">确认收货</button>
                   <i class="fa fa-history"></i>还剩{$vo['endtime']}天&nbsp;自动确认　
                  
                 </eq></neq>
                  <!-- 查看物流 , 确认收货 -->
                </div>
              </div>
            </eq>
          </eq>
        </form>
      <?php } ?>
    </div>
  </div>
</div>
<div style="padding:10px; margin-top:8px; background:#fff; color:#ff1c51; line-height:1.2;">
  <p><strong>按钮功能提醒：</strong></p>
  <p><strong>确认收货：</strong>商品送达，确认无误已签收！</p>
  <p><strong>完成订单：</strong>交易完成！</p>
  <p><strong>申请退货：</strong>退回货品，返还货款！</p>
</div>
<script>
    function refund(id){
		var remark=prompt('确定要退货么？','请输入物流单号！');
	    if(!remark){
			return false;
		}
		$.get('{:U('refund')}',{sale_id:id,remark:''+remark+''},function(data){
		

			if(data.status == 1){
				window.location.reload();
			}else{
				alert(data.info);
			}
		},'json');
	}
</script> 
<include file="Public:footer" /> 